package object_oriented

class Counter2 {
  private var value = 0
  private var name = ""
  private var step = 1
  println("the main constructor")

  def this(name: String) {
    this()
    this.name = name
    printf("the first auxiliary constructor, name: %s\n", name)
  }

  def this(name: String, step: Int) {
    this(name)
    this.step = step
    printf("the second  auxiliary constructor, name: %s, step: %d\n", name, step)
  }

  def increment(step: Int): Unit = {
    value += step
  }

  def current(): Int = value
}

object Counter2 {
  def main(args: Array[String]): Unit = {
    val c1 = new Counter2()
    val c2 = new Counter2("the 2nd Counter")
    val c3 = new Counter2("the 3th Counter", 2)
    c3.name
    c3
  }
}
